const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');//更新index.html
const {CleanWebpackPlugin} = require('clean-webpack-plugin');//清除dist文件夹

module.exports = {
	//entry: './src/index.js', //入口文件
	entry:{
		app:"./src/index.js",
		print:"./src/print.js"
	},
	devtool: 'source-map',//错误代码追踪
	devServer: {//设置本地服务器，用作热更替
	     contentBase: './dist'
	},
	plugins:[
		new CleanWebpackPlugin(),
		new HtmlWebpackPlugin({
			title:"输出成功"
		})
	],
	output: { //输出文件
		//filename: 'bundle.js',
		filename:"[name].bundle.js",
		path: path.resolve(__dirname, 'dist')
	},
	module: {
		rules: [{
				test: /\.css$/,
				use: [
					"style-loader",
					"css-loader"
				]
			},
			{
				test: /\.(png|svg|jpg|gif)$/,
				use: [{
						"loader": "url-loader",
						"options": {
							"limit": 4000
						}
					}
					//"file-loader",
				]
			},
			{
				test: /\.(woff|woff2|eot|ttf|otf)$/,
				use: [
					"file-loader"
				]
			},
			{
				test: /\.csv$/,
				use: [
					'csv-loader'
				]
			},
			//			{
			//				test: /\.json$/,
			//				use: [
			//					"json-loader"
			//
			//				]
			//			},//json是内置的，不需要安装
			{
				test: /\.xml$/,
				use: [
					"xml-loader"
				]
			}
		]
	}
};